package com.qs.education.controllers;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.qs.education.bean.api.ResponseBean;
import com.qs.education.bean.api.ResponseListBean;
import com.qs.education.bean.entity.EducationSubjectUnit;
import com.qs.education.bean.enums.ResponseStatus;
import com.qs.education.bean.utils.JsonUtil;
import com.qs.education.service.ISubjectUnitAPIService;

/**
 * @class SubjectUnitController
 * @author Leon
 * @description
 * @date Nov 19, 2018
 */
@RestController
@RequestMapping("/subjectUnit")
public class SubjectUnitController {
	
	@Autowired
	private ISubjectUnitAPIService subjectUnitApiService;
	
	private final Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * @Description 根据年级和学科 查询单元和课时
	 * @author Leon
	 * @date   Nov 20, 2018
	 * @param  
	 * @return ResponseListBean<EducationSubjectUnit>
	 */
	@RequestMapping("/findUnitAndLessonByGradeIdAndSubjectId")
	public ResponseListBean<EducationSubjectUnit> findSubjectUnitByGradeAndSubject(String bean) {
		log.info("api controller subjectUnitController findSubjectUnitByGradeAndSubject");
		EducationSubjectUnit subjectUnit = (EducationSubjectUnit) JsonUtil.jsonToBean(bean, EducationSubjectUnit.class);
		ResponseListBean<EducationSubjectUnit> unitList = new ResponseListBean<EducationSubjectUnit>();
		unitList = subjectUnitApiService.findSubjectUnitByGradeAndSubject(subjectUnit);
		return unitList;
	}
	
}
